<?php
//note these files MUST be in this order!



?>
 
<form method="get" action="#">
Term: <input type="text" value="<?php if (isset($_GET['term'])) { echo $_GET['term'];} ?>" name="term"/>
For: <select name="where">
<option>name</option>
<option>barcode</option>
<option>author</option>
<option>call</option>
</select>
<input type="hidden" name='p' value="bookman/search.php" />
<input type="submit" name="submit" />

</form>

<?php
if (isset($_GET['submit'])) {



$term = $_GET['term'];
$where = $_GET['where'];




$sql = mysql_query("select * from books where $where like '%$term%'");
$num_rows = mysql_num_rows($sql);
if ($num_rows == 0) {
echo "<font color='red'> <b><i>ERROR:</i> No Book Found Please Try Again</b> </font>";
}
while ($row = mysql_fetch_array($sql)){
	$code = $row['barcode'];
	echo '<br/> Book Name: <b>'.$row['name'];
	echo '</b><br/> Author: <b>'.$row['author'] .' ' . $row['author_last'];
	echo '</b><br/> Barcode: <b>'.$row['barcode'];
	echo "</b><form method='get' action='edit-book.php'>
<input type='submit' value='Edit Book (Edit Disabled)' name='submit' disables/>
<input type='text' value='$code' name='code' hidden/>
</form>";
	}
	}
	?>
	